﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XTYAPI.PLC;
using static XTYAPI.PLC.BitRun;

namespace XTYAPIDemo
{
    class PLCDemo
    {
        #region 编码解码
        public DECO DECO { get; set; } = new DECO();
       public ENCO ENCO { get; set; } = new ENCO();
        #endregion
        #region 一键启停
        public ALTP ALTP { get; set; } = new ALTP();
        public bool ALTPstate;
        #endregion
        #region 置位复位优先
        public bool Set { get; set; }
        public bool Rst { get; set; }
        public SR SR { get; set; } = new SR();
        public RS RS { get; set; } = new RS();

        #endregion
        #region 与
        public And And { get; set; } = new And();
        public bool CalAnd()
        {
            And.Ands = new List<bool>()
           {
               true,
               true,
               true,
               true,
               true,
               true,
               true,
               true
           };
            return And.CalAnd();
        }
        #endregion
        #region 或
        public OR OR { get; set; } = new OR();
        public bool CalOR()
        {
            OR.ORs = new List<bool>()
           {
               false,
               true,
               true,
               true,
               true,
               true,
               true,
               true
           };
            return OR.CalOR();
        }
        #endregion

        #region 数字集合计算
        public BitRun BitRun { get; private set; } = new BitRun();
        public void BitRunAdd()
        {
            #region 添加变量
            //也可以添加中文
            BitRun.AddName("启动");
            BitRun.AddName("停止");
            BitRun.AddName("输出");
            #endregion

            #region 添加逻辑指令表汇编   
            BitRun.AddMode(new List<BitValue>()
            {
                new BitValue(){Name="启动",BitMode=BitMode.LD},
                new BitValue(){Name="输出",BitMode=BitMode.OR },
                new BitValue(){Name="停止",BitMode=BitMode.AND },
                new BitValue(){Name="输出",BitMode=BitMode.OUT }
            });
            #endregion    
        }
      
       

        #endregion
    }
}
